wifi.setmode(wifi.STATION) 
wifi.sta.config({ssid="admin123", pwd="12345678"}) 
wifi.sta.connect()  

mqtt_client = mqtt.Client("wifi001",3600)
mqtt_client:on("message", function (conn,topi,message)
    -- callback函数
    print("topic: "..topic, "msg: "..message)
end)

mytmr = tmr.create()
mytmr:alarm(500,tmr.ALARM_AUTO,function ()
    ip = wifi.sta.getip()
    if ip ~= nil then
        print(ip)
        mytmr:stop()
        -- 订阅mqtt指令

        -- 连接主机
        mqtt_client:connect("10.35.155.11",function (conn)
            -- 订阅信息
            print("mqtt server connected")
            mqtt_client:subscribe("wifi_cmd",0) -- 主题
            
        end)
    end
end)
